]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
magnifier: Don't query pointer unless necessary
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 29 Jul 2021 19:56:57 +0000 (21:56 +0200)
committerMarge Bot <marge-bot@gnome.org>
Sat, 31 Jul 2021 17:18:08 +0000 (17:18 +0000)
The PointerWatcher passes the current pointer position to every watch,
so we don't have to query the pointer again scrollToMousePos() is used
as watch callback.

While that should be the only use, be conservative and still query the
pointer when called without arguments.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1932>

js/ui/magnifier.js

index 08466b9a0986a8a597eceae855b2da6a8a317aab..f170bbed01cfb5880ab003d56fd98c63562c838d 100644 (file)
@@ -230,8 +230,8 @@ var Magnifier = class Magnifier {
      * system pointer.
      * @returns {bool} true.
      */
-    scrollToMousePos() {
-        let [xMouse, yMouse] = global.get_pointer();
+    scrollToMousePos(...args) {
+        const [xMouse, yMouse] = args.length ? args : global.get_pointer();
 
         if (xMouse != this.xMouse || yMouse != this.yMouse) {
             this.xMouse = xMouse;